#!/bin/gawk -f

BEGIN {
    bin = 0.5
    min = 0
    max = 17
    printf( "    ", key )
    for ( i=min; i<=max; i++ ) {
	array[i] = 0
        printf( "%4.1f", i*bin )
    }
    printf( "\n" )
}

function summary() {
    printf( "%-4s", key )
    for ( i=min; i<=max; i++ ) {
	if ( array[i] != 0 ) {
	    printf( "%4i", array[i] )
	    array[i] = 0
	}
	else
	    printf( "    " )
    }
    printf( "\n" )
}

NR == 1 { key = $1 }

{
    if ( $1 != key ) {
	summary()
	key = $1
    }
    if ( NF == 3 )
	low = $3
    else
	low = 1.8
    val = ( $2 - low )/ bin
    sub( /\..*/, "", val )
    val += 0
    if ( val < min || val > max ) {
	print "OUT OF RANGE"
	print $0, val
	exit( 1 )
    }
    array[val]++
}

END {
    summary()
}
